﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint.WebControls;

namespace TST.SharePointObjects
{
    public class SOPageBase : LayoutsPageBase
    {
        private SharePointObjectsDatabase _database;
        protected VersionInfo _versionInfo;

        protected SharePointObjectsDatabase Database
        {
            get
            {
                if (_database == null)
                {
                    _database = SharePointObjectsDatabase.GetDatabase();
                }
                return _database;
            }
            set
            {
                _database = value;
            }
        }

        protected VersionInfo VersionInfo
        {
            get
            {
                if (_versionInfo == null)
                {
                    _versionInfo = new VersionInfo(Database);
                }
                return _versionInfo; 
            }
        }

        protected override void OnLoad(EventArgs e)
        {
            //if (VersionInfo.DatabaseVersion < Database.CURRENTDATABASEVERSION &&
            //    VersionInfo.License.LicensingMode != LicensingMode.Demo && 
            //    VersionInfo.License.LicensingMode != LicensingMode.FullLicense)
            //{
            //    throw new Exception("Your version of SharePoint Objects is not configured properly. Contact your SharePoint administrator.");
            //}
            base.OnLoad(e);
        }
    }
}
